{$CLEO}

const
//-+--Variable's
Obj         = 0@
X           = 1@
Y           = 2@
Z           = 3@
Wp          = 4@
Sfx         = 6@
EX_X        = 7@
EX_Y        = 8@
EX_Z        = 9@

//-+--Actor
PlayerA =$player_actor

//-+--Directory
Sfx_d = "cleo\shark-o-matic\sound\explosion.mp3"

end

//-+--INI
0AF0: 5@ = get_int_from_ini_file "cleo\shark-o-matic.ini" section "settings" key "active_mod"

0000:   //-+--Shark-O-Matic Gun

:Check                              
if  8AAB: not  file_exists "cleo\shark-o-matic.ini"
jf @Checked
0ACD: show_text_highpriority "~r~ERROR 'Shark-O-Matic.ini': File not found.~n~Arquivo nao encontrado." time 4000
wait 4000
0A93: end_custom_thread

:Checked
wait 0
if and
5@ == 1  
0ADC:   test_cheat "SHARK"
jf @Check
0ACD: show_text_highpriority "Shark-O-Matic Enabled" time 4000

:Start  
while true                  
if  Player.Defined($player_char)
then       
    0470: Wp = actor PlayerA current_weapon
    if and  
    Wp > 15
    02D8:   actor PlayerA current_weapon == Wp
    then
        {$INCLUDE forallpeds}
        if and  
        056D:   actor ped defined
        803C:  not PlayerA == ped // (int) 
        then
            if and  
            051A:   actor ped damaged_by_actor PlayerA
            not Actor.Dead(ped)                    
            then                              
                0467: clear_actor ped last_weapon_damage
                04D7: set_actor ped locked 1
                Gosub @Load_Model
                Gosub @Create_Shark           
                0321: AS_actor ped die_headshotted
                Gosub @Destroy_Shark    
                Gosub @Release_Model        
                end                          
                    if  0ADC:   test_cheat "SHARK"
                    then
                        Audiostream.Release(Sfx)
                        0ACD: show_text_highpriority "Shark-O-Matic Disabled" time 4000   
                        jump @Checked       
                        {$INCLUDE for_end}
                        end
                     end
                  end
               end
           wait 0
        end                                         
                                            
                                    




//-+--Gosubs Helpers

:Load_Model   
Model.Load(1608)
038B: load_requested_models
return


:Create_Shark                          
04C4: store_coords_to X Y Z from_actor ped with_offset 0.0 0.0 -7.3
04C4: store_coords_to EX_X EX_Y EX_Z from_actor ped with_offset 0.0 0.0 0.0
Sfx = Audiostream.Load(Sfx_d)

0107: obj = create_object 1608 at X Y Z
0382: set_object obj collision_detection 1
02CE: Z = ground_z_at EX_X EX_Y EX_Z
0565: create_soundless_explosion_at EX_X EX_Y EX_Z type 100
0003: shake_camera 130       
Audiostream.PerformAction(Sfx, PLAY)
                                       
25@ = -7.3
repeat
    if 056D:   actor ped defined
    jf break                                                                                   
    069B: attach_object obj to_actor ped with_offset 0.0 0.0 25@ rotation 100.0 0.0 0.0
    007F: 25@ -= frame_delta_time * 0.1
until 25@ < -1.8                                                                                
return


                                                                                                    
:Destroy_Shark                                                    
25@ = -1.8
repeat
    wait 0 
    if 056D:   actor ped defined
    jf break                                                                                   
    069B: attach_object obj to_actor ped with_offset 0.0 0.0 25@ rotation 100.0 0.0 0.0
    007F: 25@ -= frame_delta_time * 0.1 
until 25@ < -7.3     

Actor.DestroyInstantly(ped)
Object.Destroy(obj)
return


:Release_Model                    
0249: release_model 1608
return